#ifndef YAMLVALIDATOR_H
#define	YAMLVALIDATOR_H

#include "Format.h"

#define syvIgnoreAllowNull      0x00000001 // When set allowNull has no effect.
#define syvUndefinedKeysIllegal 0x00000002 // When set keys that aren't defined in the format cause complete invalidity.
#define syvCopyInput            0x00000004 // Copy the input, or refer to it.

class YamlValidator {
public:
    YamlValidator(FormatValidator v, YAML::Node n, unsigned int flags = 0);
    inline bool isValid() { return valid; }

    /**
     * Gets the actual value frome a node path as used in getNode.
     * Returns Node containing value.
     * If no value provided at location, returns Node of default.
     * If no Node represents the whole default value, as in structs with default values for some or
     * all members, which may be structs themselves, a new Node is constructed with all defaults
     * (the actual default Nodes) and returned.
     */
    YAML::Node getValue(const std::string path) const throw (ValidityException);

private:
    bool valid;
    unsigned int flags;
    FormatValidator&format;
    YAML::Node values;
    bool validate(YAML::Node n) const throw (ValidityException);
    bool containsRequiredFields(YAML::Node f) const;
    bool validateSection(std::string where, YAML::Node f, YAML::Node n) const throw (ValidityException);
    YAML::Node getBaseVarDef(std::string path, std::string&left) const;
    YAML::Node findTypeDefinitionOfVariableByPath(std::string path) const;
    YAML::Node getDefaultValueOfSection(YAML::Node def) const throw (ValidityException);
};

#endif	/* YAMLVALIDATOR_H */
